﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using KaoQin.BLL;

namespace KaoQin.WPFApp.kaoQin
{
    /// <summary>
    /// NoList.xaml 的交互逻辑
    /// </summary>
    public partial class NoList : Window
    {
        public NoList()
        {
            InitializeComponent();
        }


        private DateTime beginTime;
        private DateTime endTime;
        private int RecordCount;
        private int state;

        public NoList(int _RecordCount, int _state, DateTime _beginTime, DateTime _endTime)
        {
            InitializeComponent();

            state = _state;
            beginTime = _beginTime;
            endTime = _endTime;
            RecordCount = _RecordCount;
            bindList();
        }




        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            bindList();
        }

        private void bindList()
        {
            SpecialCmd bll = new SpecialCmd();
            try
            {
                if (state == 0)
                {
                    pager.TotalCount = RecordCount;
                    lsv.ItemsSource = bll.GetBeginNoList(beginTime, endTime, txtUserName.Text.Trim(), txtWorkNum.Text.Trim(), pager.PageSize, pager.PageIndex).Tables[0].DefaultView;
                }
                else if (state == 1)
                {
                    pager.TotalCount = RecordCount;
                    lsv.ItemsSource = bll.GetEndNoList(beginTime, endTime, txtUserName.Text.Trim(), txtWorkNum.Text.Trim(), pager.PageSize, pager.PageIndex).Tables[0].DefaultView;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("绑定数据出错了:" + ex.Message);
            }
        }

        private void DataPager_PageChanged(object sender, DataPager.PageChangedEventArgs e)
        {
            bindList();
        }
    }
}
